<!DOCTYPE html>
<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <!-- Meta, title, CSS, favicons, etc. -->
    <meta charset="utf-8">
    
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <title>${_title}</title>

    <!-- Bootstrap core CSS -->

    <link href="${_css}/bootstrap.min.css" rel="stylesheet">

    <link href="${_font}/css/font-awesome.min.css" rel="stylesheet">
    <link href="${_css}/animate.min.css" rel="stylesheet">

    <!-- Custom styling plus plugins -->
    <link href="${_css}/custom.css" rel="stylesheet">
    <link href="${_css}/icheck/flat/green.css" rel="stylesheet">
    <link href="${_css}/datatables/tools/css/dataTables.tableTools.css" rel="stylesheet">

    <script src="${_js}/jquery.min.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
	<style>
		td a{
			cursor:pointer
		}
	</style>
</head>


<body style="background: #F7F7F7;">
<div class="">
    <div class="row">
        <div class="col-md-12 col-sm-12 col-xs-12">
            <div class="x_panel">
	            <div class="x_title">
					<h2>新手借款标列表</h2>
					<div class="clearfix"></div>
				</div>
            </div>
            <div class="scroll">
                <div class="x_content">
                    <table id="example" data-action="/admin/borrow/listNewBorrow?1=1" class="table table-striped responsive-utilities jambo_table">
                        <thead>
                            <tr class="headings">
                                <th>序号 </th>
                                <th>编号 </th>
                                <th>标题</th>
                                <th>状态</th>
                                <th>借款总额(￥)</th>
                                <th>已投资金额 (￥)</th>
                                <th>未投资金额(￥)</th>
                                <th>年化率</th>
                                <th>投资进度</th>
                                <th>还款方式</th>
                                <th>发标时间 </th>
                                <th>定时显示时间 </th>
                                <th>满标时间 </th>
                                <th>理论还款时间 </th>
                                <th>操作</th>
                            </tr>
                        </thead>

                        <tbody>
			                <#if (pageInfo.pageList?size > 0)>
								<#list pageInfo.pageList as model>
									<tr class="even pointer">
		                                <td>
		                                	${model_index+1}
		                                </td>
		                                <td>
		                                	<#if model.code??>
		                                		${model.code}
		                                	</#if>
		                                </td>
		                                <td style="overflow:hidden;text-overflow: ellipsis;white-space: nowrap;word-break: keep-all;display: inline-block;width: 150px;">
		                                	<a href="/invest/detail?bid=${model.id}" target="_blank">${model.title}</a>
		                                </td>
		                                <td>
		                                	<#if model.status?exists>
		                                		<#if (model.status=='borrow' || model.status=='new' )>
		                                			投资中
		                                		<#elseif model.status=='check'>
		                                			复审中
		                                		<#elseif model.status=='expire'>
		                                			已过期/流标
	                                			<#elseif model.status=='pay'>
	                                				<#if model.isBuyBack?? && model.isBuyBack =="Y">
							                    		回购中
						                    		<#else>
							                    		还款中
						                    		</#if>
	                                			<#elseif model.status=='complete'>
	                                				已还完
		                                		</#if>
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if model.amount?exists>
		                                		<#if (model.amount != 0 )>
			                                		${model.amount?string('#.00')}
			                                	<#else>
			                                	 	${model.amount?string('0.00')}
			                                	</#if>
		                                	</#if>
		                                </td>
		                                <td>
		                                	<#if model.tenderMoney?exists>
		                                		<#if (model.tenderMoney != 0 )>
			                                		${model.tenderMoney?string('#.00')}
			                                	<#else>
			                                	 	${model.tenderMoney?string('0.00')}
			                                	</#if>
		                                	</#if>
		                                </td>		                                
		                                <td>	
		                                	<#if model.notTenderMoney?exists>
		                                		<#if (model.notTenderMoney != 0 )>
			                                		${model.notTenderMoney?string('#.00')}
			                                	<#else>
			                                	 	${model.notTenderMoney?string('0.00')}
			                                	</#if>
		                                	</#if>
		                                </td>		                                		                                
		                                <td>
		                                	${model.percent}%
		                                </td>
										<td class="project_progress">
                                            <div class="progress progress_sm">
                                                <div class="progress-bar bg-green" role="progressbar" data-transitiongoal="${model.schedules}" aria-valuenow="${model.schedules-1}" style="width: ${model.schedules}%;"></div>
                                            </div>
                                            <small>
                                            	已完成
                                            	<#if model.schedules?exists>
					                            	${model.schedules?string('0.00')}%
					                            </#if>
                                            </small>
                                        </td>
		                                <td>
		                                	<#if model.paymentMode?exists>
		                                		<#if model.paymentMode==0>
		                                			一次性还款
		                                		<#elseif model.paymentMode==1>
		                                			按月付息到期还本
		                                		<#elseif model.paymentMode==2>
		                                			等额本息
		                                		</#if>
		                                	</#if>
		                                </td>
		                                <td>
		                                	${(model.createTime?string("yyyy-MM-dd HH:mm"))!}	                                	
		                                </td>
		                                <td>
		                                	<#if model.timingShow??>
		                                		${(model.timingShow?string("yyyy-MM-dd HH:mm:ss"))}	   	
		                                	</#if>
		                                </td>	
		                                <td>
	                                		${(model.checkTime?string("yyyy-MM-dd HH:mm"))!}	
		                                </td>
		                                <td>
	                                		${(model.paymentTime?string("yyyy-MM-dd HH:mm"))!}	
		                                </td>				                                		                                	                                	                                
		                                 <td>
		                                 	<#if (model.status=="new" || model.status=="borrow")>
		                                		 <a class="btn-intercept" data-id="${model.id}">截标</a>&nbsp;&nbsp;
		                                	<#elseif model.status=="check">
		                                		 <a class="btn-complete" data-id="${model.id}">满标复审</a>&nbsp;&nbsp;
		                                	<#elseif model.status="complete">
		                                		 <a class="btn-pay" data-id="${model.id}" href="/admin/borrowPayment/listBorrowPayment?borrowId=${model.id}">查看还款</a>&nbsp;&nbsp; 
		                                	<#elseif model.status="expire">
		                                		 <a class="btn-expire" data-id="${model.id}" href="javascript:;">续期</a>&nbsp;&nbsp;		   
		                        			</#if>       
		                        			<a class="btn-detail" data-id="${model.id}" href="/admin/borrow/detailBorrow?borrowId=${model.id}">查看详细信息</a>
		                                </td>
		                             </tr>   
		                        </#list>
							<#else>
								<tr class="even pointer">
									<td colspan="15">无记录</td>
								</tr>
							</#if>
                        </tbody>
                    </table>
                    <#if (pageInfo.pageList?size > 0)>
	                	<#include "../base/Page.ftl">
	                </#if>
	                <div>
	                	<#if (pageInfo.pageList?size > 0)>
	                		共计：<span style="color:#1ABB9C">${pageInfo.total}</span>笔，
	                		借款总额：<span style="color:#1ABB9C">${pageInfo.sum?string('0.00')}</span>元，
							剩余本金：<span style="color:#1ABB9C">${pageInfo.sumBlance?string('0.00')}</span>元，
							已还总额：<span style="color:#1ABB9C">${pageInfo.sumFee?string('0.00')}</span>元
	                	</#if>
	                </div>
                </div>
            </div>
        </div>
        <br />
        <br />
        <br />
    </div>
</div>

<script src="${_js}/bootstrap.min.js"></script>

<!-- bootstrap progress js -->
<script src="${_js}/progressbar/bootstrap-progressbar.min.js" type="text/javascript"></script>
<script src="${_js}/nicescroll/jquery.nicescroll.min.js" type="text/javascript"></script>
<!-- icheck -->
<script src="${_js}/icheck/icheck.min.js" type="text/javascript"></script>

<script src="${_js}/custom.js" type="text/javascript"></script>

<!-- PNotify -->
<script src="${_js}/notify/pnotify.core.js" type="text/javascript"></script>
<script src="${_js}/notify/pnotify.buttons.js" type="text/javascript"></script>
<script src="${_js}/notify/pnotify.nonblock.js" type="text/javascript" ></script>

<script type="text/javascript" src="${_front_js}/layer/layer.js" ></script>
<script type="text/javascript" src="${_front_js}/layer/extend/layer.ext.js" ></script>

<script>
    $(document).ready(function () {
        $('input.tableflat').iCheck({
            checkboxClass: 'icheckbox_flat-green',
            radioClass: 'iradio_flat-green'
        });
        
        
        $(".btn-complete").click(function(){
        	var id=$(this).attr("data-id");
        	if(confirm('你确定要进行满标复审吗 ？')){
        		var index = layer.load(1,{shade: [0.8, '#393D49']});
	        	$.ajax({
		            type: 'post',
		            dataType: 'JSON',
		            async:'false',
		            url: '/admin/tender/completeTenderNewBorrow',
		            data:{tid:id},
		            success: function(result){
		            	layer.close(index);
		            	if(result.code==-1){
				        	alert("满标复审成功");   
				        	window.location.reload()
		            	}else{
		            	    new PNotify({
				            	title: '操作提示',
				            	text: result.msg,
				            	delay: 3e3,
				            	type: 'error'
				        	});	   	 
				        	return false;           	
		            	}
		            }
	            });        		
        	}

        })
    });
    
    $(".btn-repay").click(function(){
		var id=$(this).attr("data-id");
		var uid=$(this).attr("data-uid");
    	if(confirm('确定还款吗 ？')){
        	$.ajax({
	            type: 'post',
	            dataType: 'JSON',
	            async:'false',
	            url: '/admin/borrow/newBorrowpayment',
	            data:{borrowId:id},
	            success: function(result){
	            	if(result.code==-1){
			        	alert("还款成功！");   
			        	window.location.reload()
	            	}else{
	            	    new PNotify({
			            	title: '操作提示',
			            	text: result.msg,
			            	delay: 3e3,
			            	type: 'error'
			        	});	   	 
			        	return false;           	
	            	}
	            }
            });        		
    	}
    });
    
    $(".btn-copy").click(function(){
    	var borrowId = $(this).attr("data-id");
    	$.ajax({
            type: 'post',
            dataType: 'JSON',
            async:'false',
            url: '/admin/borrow/copy',
            data:{borrowId:borrowId},
            success: function(result){
            	alert(result.msg);
            	if(result.code==-1){
		        	window.location.reload();
            	}else{
            		if(result.code == 0){
						top.location.href = "/admin/login";
					}
            	}
            }
        });    
    });
    
    $(".btn-intercept").click(function(){
		var id=$(this).attr("data-id");
		var uid=$(this).attr("data-uid");
    	if(confirm('确定截标吗 ？')){
        	$.ajax({
	            type: 'post',
	            dataType: 'JSON',
	            async:'false',
	            url: '/admin/borrow/new/intercept',
	            data:{borrowId:id},
	            success: function(result){
	            	if(result.code==-1){
			        	alert(result.msg);   
			        	window.location.reload()
	            	}else{
	            	    new PNotify({
			            	title: '操作提示',
			            	text: result.msg,
			            	delay: 3e3,
			            	type: 'error'
			        	});	   	 
			        	return false;           	
	            	}
	            }
            });        		
    	}
    });
    
    function initData(action) { 
    	var status = $("#status").find("option:selected").val();
    	if(status != -1){
    		action += "&status="+status;
    	}
		window.location.href=action;
	} 
	
	$(".btn-info").click(function(){
		initData($("#example").attr('data-action'));
	});
	
</script>
</body>

</html>